$menu-prefix: "puzzle-menu";

// menu
$menu-border-width: $border-width !default;
$menu-border-color: $border-color !default;
$menu-box-shadow: inset 0 1px 0 rgba($white, 0.15),
  0 1px 1px rgba($black, 0.075) !default;
$menu-transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out !default;

// menu-item
$menu-item-padding-y: 0.5rem !default;
$menu-item-padding-x: 1rem !default;
$menu-item-active-color: $primary !default;
$menu-item-active-border-width: 2px !default;
$menu-item-disabled-color: $gray-600 !default;

//sub-menu
$submenu-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
  0 0 6px 0 rgba(0, 0, 0, 0.04);

.#{$menu-prefix} {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 30px;
  list-style: none;
  border-bottom: $menu-border-width solid $menu-border-color;
  box-shadow: $menu-box-shadow;

  &-item,
  &-sub {
    padding: $menu-item-padding-y $menu-item-padding-x;
    transition: $menu-transition;
    border-bottom: $menu-item-active-border-width solid transparent;
    cursor: pointer;
  }

  &-item {
    white-space: nowrap;

    &:hover,
    &:focus {
      text-decoration: none;
    }

    &-disabled {
      color: $menu-item-disabled-color;
      // cursor: not-allowed;
      pointer-events: none;
    }

    &-active,
    &:hover {
      color: $menu-item-active-color;
      border-bottom: $menu-item-active-border-width solid
        $menu-item-active-color;
    }
  }

  &-sub {
    position: relative;
    display: flex;
    align-items: center;

    &-title {
      display: flex;
      align-items: center;

      .puzzle-icon-angle-down {
        margin-left: 4px;
        transition: transform 0.25s ease-in-out;
      }
    }

    &:hover {
      .puzzle-icon-angle-down {
        transform: rotate(180deg);
      }
    }

    &-item {
      position: absolute;
      top: calc(100% + 8px);
      left: 0;
      padding-left: 0;
      border: $menu-border-width solid $menu-border-color;
      box-shadow: $submenu-box-shadow;
      background: $white;
      z-index: 100;
      list-style: none;

      > .#{$menu-prefix}-item {
        border-bottom: $menu-item-active-border-width solid transparent;
      }
    }
  }

  &.#{$menu-prefix}-v {
    flex-direction: column;

    .#{$menu-prefix}-item {
      border-left: $menu-item-active-border-width solid transparent;
      border-bottom: 0;

      &-active,
      &:hover {
        border-left: $menu-item-active-border-width solid
          $menu-item-active-color;
      }
    }

    .#{$menu-prefix}-sub {
      display: flex;
      flex-direction: column;
      align-items: flex-start;

      &:hover {
        .puzzle-icon-angle-down {
          transform: rotate(0deg);
        }
      }

      &-item {
        position: relative;
        top: 0;
        border: none;
        box-shadow: none;
        padding-left: $menu-item-padding-x;
        z-index: 0;
      }

      &.#{$menu-prefix}-sub-opened {
        .puzzle-icon-angle-down {
          transform: rotate(180deg);
        }
      }
    }
  }
}
